<!--
 * @Description: 底部第二个
 * @Author: Ronda
 * @Date: 2022-02-16 09:30:08
 * @LastEditors: Ronda
 * @LastEditTime: 2022-05-18 17:24:31
-->
<template>
  <div><div ref="container" style="height: 150px"></div></div>
</template>

<script>
import { Scatter } from '@antv/g2plot';
export default {
  data() {
    return {};
  },
  computed: {},
  methods: {
    createScatter() {
      fetch('https://gw.alipayobjects.com/os/antfincdn/t81X1wXdoj/scatter-data.json')
  .then((res) => res.json())
  .then((data) => {
    const scatterPlot = new Scatter(this.$refs.container, {
      appendPadding: 8,
      data,
      xField: 'x',
      yField: 'y',
      colorField: 'genre',
      color: [
        'r(0.4, 0.3, 0.7) 0:rgba(255,255,255,0.5) 1:#5B8FF9',
        'r(0.4, 0.4, 0.7) 0:rgba(255,255,255,0.5) 1:#61DDAA',
      ],
      sizeField: 'size',
      size: [6, 9],
      shape: 'circle',
      yAxis: {
        nice: true,
        grid: {
          line: {
            style: {
              stroke: '#01245a',
            },
          },
        },
        line: {
          style: {
            stroke: '#01245a',
          },
        },
      },
      xAxis: {
        grid: {
          line: {
            style: {
              stroke: '#01245a',
            },
          },
        },
        line: {
          style: {
            stroke: '#01245a',
          },
        },
      },
    });
    scatterPlot.render();
  });
    },
  },
  created() {},
  mounted() {this.createScatter()},
};
</script>
<style scoped>
</style>